#include <iostream>
#include <cmath>
using namespace std;

typedef long long LL;

int main()
{
    int t; cin >> t;
    while(t--)
    {
        LL l, r, k; cin >> l >> r >> k;
        LL ans = r / k - l + 1;
        if(ans < 0) ans = 0;
        cout << ans << endl;
    }
    return 0;
}